<div id="commonprice_search_div"></div>
<script>
    Ext.onReady(function(){
        var loginID = new Ext.form.TextField({
            fieldLabel: '登录ID',
            //allowBlank: false,
            name: 'login_id',
            anchor: '90%'
        });
        var airportTpl = new Ext.XTemplate('<tpl for="."><div class="search-item">', '{airport_name}({airport_code})', '</div></tpl>');
        var fromAirport = new Ext.form.ComboBox({
            store: new Ext.data.Store({
                proxy: new Ext.data.HttpProxy({
                    url: "/admin/getAllAirportComboBox"
                }),
                reader: new Ext.data.JsonReader({
                    root: 'root'
                }, [{
                        name: 'id'
                    }, {
                        name: 'airport_name'
                    }, {
                        name: 'airport_code'
                    }])
            }),
            fieldLabel: "<span class='red'>*</span>始发城市",
            name: 'from_airport',
            //allowBlank: false,
            blankText: "始发城市必须选择",
            emptyText: '拼音首字母/代码',
            typeAhead: false,
            loadingText: '正在查找...',
            hideTrigger: false,
            tpl: airportTpl,
            minChars: 0,
            width: '230',
            itemSelector: 'div.search-item',
            onSelect: function(record){
                fromAirport.setValue(record.data.airport_name);
                from.setValue(record.data.airport_code);
                if (this.isExpanded()) {
                    this.collapse();
                }
            }
        });
        fromAirport.on("focus",function(){this.selectText();});
        var toAirport = new Ext.form.ComboBox({
            store: new Ext.data.Store({
                proxy: new Ext.data.HttpProxy({
                    url: "/admin/getAllAirportComboBox"
                }),
                reader: new Ext.data.JsonReader({
                    root: 'root'
                }, [{
                        name: 'id'
                    }, {
                        name: 'airport_name'
                    }, {
                        name: 'airport_code'
                    }])
            }),
            fieldLabel: "<span class='red'>*</span>目的城市",
            name: 'to_airport',
            //allowBlank: false,
            blankText: "目的城市必须选择",
            emptyText: '拼音首字母/代码',
            typeAhead: false,
            loadingText: '正在查找...',
            hideTrigger: false,
            tpl: airportTpl,
            minChars: 0,
            width: '230',
            itemSelector: 'div.search-item',
            onSelect: function(record){
                toAirport.setValue(record.data.airport_name);
                to.setValue(record.data.airport_code);
                if (this.isExpanded()) {
                    this.collapse();
                }
            }
        });
        toAirport.on("focus",function(){this.selectText();});
        var from = new Ext.form.Hidden({
            name: 'from'
        });
        var to = new Ext.form.Hidden({
            name: 'to'
        });
        var searchButton = new Ext.Button({
            text: '搜 索',
            handler: searchByOrderID
        })
        var formPanel = new Ext.form.FormPanel({
            //baseCls: 'x-plain',
            labelWidth: 65,
            width: '900',
            labelAlign: 'right',
            frame: true,
            items: [{
                    layout: 'column',
                    border: false,
                    items: [{
                            columnWidth: .2,
                            layout: 'form',
                            border: false,
                            items: [loginID]
                        },{
                            columnWidth: .3,
                            layout: 'form',
                            border: false,
                            items: [fromAirport]
                        },{
                            columnWidth: .3,
                            layout: 'form',
                            border: false,
                            items: [toAirport]
                        },{
                            columnWidth: .1,
                            layout: 'form',
                            border: false,
                            items: [searchButton]
                        }]
                }]
        });
        formPanel.render('commonprice_search_div');
        function searchByOrderID(){
            if (formPanel.form.isValid()) {
                priceReleasedListDS.removeAll();
                priceReleasedListDS.baseParams.login_id = loginID.getValue();
                priceReleasedListDS.baseParams.fromto = from.getValue() + to.getValue();
                priceReleasedListDS.load({
                    params: {
                        start: 0,
                        limit: 10
                    }
                });
                priceReleasedListDS.baseParams.login_id = null;
                priceReleasedListDS.baseParams.fromto = null;
            }
            //alert();
        }
    });
</script>